import datetime
import netWorkGetWay
import logs

print("demo start!!!!!!!!!!!!!!!!!")
last_date = datetime.datetime.now().timestamp()
last_date = int(last_date * 1000)kil
logs.addLog("发送端启动！")
while True:
    try:
        datafile = open("./data.txt", "r")
        timefile = open("./time.txt", "r")

        time_txt = int(timefile.read())
        data_txt = datafile.readline()
        if time_txt > last_date:
            # 数据新
            if time_txt - last_date > 300:
                print("[" + str(time_txt) + "] " + str(data_txt))
                netWorkGetWay.sendmsg(data_txt.encode("utf-8"), "192.255.255.255", "8849")
                logs.addLog("有效射击一发", data_txt)
                time_date = time_txt
                last_date = data_txt
            else:
                logs.addLog("300ms重复数据过滤", data_txt)
    except:
        print(".", end=" ")
